package app.gui;

import color.Rgb;
import processing.core.PApplet;
import app.ProgressListener;

public class ProgressBar implements ProgressListener, Drawable{
	float x, y, w, h;
	public float val;
	String task;
	Rgb color;
	
	
	
	public ProgressBar(float x, float y, float w, float h, Rgb color) {
		super();
		this.x = x;
		this.y = y;
		this.w = w;
		this.h = h;
		this.task = task;
		this.color = color;
		val = 0;
	}
	public void progress(String task, float progress) {
		
		val = progress;
		if(val < 0) val = 0;
		if(val > 1) val = 1;
	}
	public void draw(PApplet pa) {
		color.fill(pa);
		if(h > w)
			pa.rect(x, y, w, h * val);
		else
			pa.rect(x, y, w * val, h);
	}
	
	
}
